package com.example.demo.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by pengwan on 2017/7/23.
 */
@Entity
@Table(name = "department")
public class Department extends EntityId{
    @Column(name = "department_name")
    private String name;
    @Embedded
    private Address address;

    @OneToMany(mappedBy = "department") // 关系反方
    @JsonIgnore // 防止陷入了死循环
    private Collection<Teacher> teachers;

    @OneToMany(mappedBy = "department") // 关系反方
    @JsonIgnore // 防止陷入了死循环
    private Collection<Student> students;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Collection<Teacher> getTeachers() {
        return teachers;
    }

    public void setTeachers(Collection<Teacher> teachers) {
        this.teachers = teachers;
    }

    public Collection<Student> getStudents() {
        return students;
    }

    public void setStudents(Collection<Student> students) {
        this.students = students;
    }
}
